const bodyParser = require("koa-bodyparser");

const Koa = require("koa");


const app = new Koa();
app.use(bodyParser());

app.use(async (ctx, next) => {
  ctx.set('Access-Control-Allow-Origin', 'http://localhost:3000');
  ctx.set('Access-Control-Allow-Methods', 'PUT,DELETE,POST,GET');
  await next();
});



const indexRouter = require("./routes/index");
const detailRouter = require("./routes/detail");
const userRouter = require("./routes/user");
const cartRouter = require("./routes/cart");
const cationRouter = require("./routes/cation");
const shopstoreRouter = require("./routes/shopstore");
const designerRouter = require("./routes/designer");
const mycollectionRouter = require("./routes/mycollection");
const addressRouter = require("./routes/address");


app.use(indexRouter.routes());
app.use(detailRouter.routes());
app.use(userRouter.routes());
app.use(cartRouter.routes());
app.use(cationRouter.routes());
app.use(shopstoreRouter.routes());
app.use(designerRouter.routes());
app.use(mycollectionRouter.routes());
app.use(addressRouter.routes());


app.listen(4000);
